package com.jack.thinking.thread;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public class UnsafeCachingFactorizer implements Runnable{

	private static final AtomicInteger in = new AtomicInteger(1);
	private static final AtomicLong lo = new AtomicLong(1);
	
	@Override
	public void run() {
		if(lo.get() != in.get()) {
			System.out.println("not same value");
		}else {
			lo.incrementAndGet();
			/*try {
				Random r = new Random(System.currentTimeMillis());
				Thread.sleep(r.nextInt(10));
			} catch (InterruptedException e) {
				System.out.println(e);
			}*/
			in.incrementAndGet();
			System.out.println(lo.get() + "======" + in.get());
		}
	}
	
	public static void main(String[] args) {
		for(int i =0 ; i < 20; i++) {
			Thread thread = new Thread(new UnsafeCachingFactorizer());
			thread.start();
		}
	}
}
